package com.ita.util;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public final class HibernateUtil {
    private static SessionFactory sessionFactory;
    private HibernateUtil(){
    }
    //初始化

    static{
  	  Configuration config = new Configuration();
  	config.configure();
   	  sessionFactory =config.buildSessionFactory();
    }    
    
    public static SessionFactory getSessionFactory(){
  	      return sessionFactory;
    }
   
    public static Session getSession(){
  	     return sessionFactory.openSession();
    }

}
